const personal1=document.querySelector('.personal1')
const userdata={
    userId: 0,
    username: "string",
    password: "string",
    email: "string",
    mobile: "string",
    startWorkYear: 0,
    profession: "string",
    introduction: "string",
    company: "string",
    position: "string",
    interests: "string",
    avatar: "string"
}
function Getuserinfo(key){
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/get/userinfo`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText);
            console.log(response)
            for(const key in response.data){
                if(userdata.hasOwnProperty(key)){
                    userdata[key]=response.data[key]
                }
            }
            console.log(userdata)
            greetingsection.innerHTML = `
                    <h3>上午好！${userdata.username}</h3>
                    <button class="signin-btn">去签到</button>
                `
            personal1.innerHTML=`
                    <button class="nav-button createCenter">创作者中心</button>
                    <button class="nav-button">会员</button>
                    <button class="nav-button avatar1">
                        <img src="${userdata.avatar}" alt="" style="width: 35px;height: 35px;border-radius: 50%" class="userAvatar">
                    </button>
                    <button class="nav-button">退出登录</button>
                `
        }
    }
}



let current2=1
let followingArray=[]
function CheckFollowingstatus(key){
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/follower?current=${current2}`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText)
            console.log("获取到的关注列11111表为",response)
            /*
            *
            * 这是用户关注列表
            *
            * */
            if(response.data.records.length > 0){
                response.data.records.forEach(item => {
                    followingArray.push(item)
                })
                current2++
                CheckFollowingstatus(key)
            }
            else{
                current2=1
                console.log("所有关注者数据已经加载完毕",followingArray)
                console.log("所有数据已经加载完毕,这是我的关注者的数组",followingArray)
                const articleContainer=document.querySelector('.articleContainer')
                articleContainer.innerHTML=``
                const formGroup=document.querySelector('.form-group1')
                formGroup.innerHTML=``
                followingArray.forEach(item=>{
                    const div = document.createElement('div')
                    div.setAttribute('userId', item.userId)
                    div.innerHTML = `
                        <div class="tech-item">
                            <div class="tech-left">
                                <div class="tech-icon css-icon">
                                       <img src="${item.avatar}" alt="" style="width: 100%; height: 100%" class="SeeHisPage">
                                </div>
                                <span class="tech-name">${item.username}</span>
                            </div>
                            <button class="follow-btn1 deleteFollow">已关注</button>
                        </div>
                    `
                    articleContainer.appendChild(div)
                })
            }
        }
    }
}

let current3=1
let collectArray=[]
function GetmyCollectArticle(key){
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/collected-articles?current=${current3}`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText)
            console.log("当前的收藏文章数为:",response)
            if(response.data.records.length > 0){
                response.data.records.forEach(item => {
                    collectArray.push(item)
                })
                current3++
                GetmyCollectArticle(key)

            }
            else{
                current3=1
                console.log("所有收藏文章数据已经加载完毕",collectArray)
            }
        }
    }
}

let current4=1
let likeArray=[]
function GetmyLikeArticle(key){
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/liked-articles?current=${current4}`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText)
            console.log("当前获取到的喜欢文章数组是:",response)
            if(response.data.records.length > 0){
                response.data.records.forEach(item => {
                    likeArray.push(item)
                })
                current4++
                GetmyLikeArticle(key)

            }
            else{
                current4=1
                console.log("当前我喜欢的文章数组已经加载完毕",likeArray)
            }
        }
    }
}

let current5=1
let FansArray=[]
/*
*
* 当前并没有粉丝
*
* */
function GetmyFans(key){
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/following?current=${current5}`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText)
            console.log(response)
            if(response.data.records.length > 0){
                response.data.records.forEach(item => {
                    FansArray.push(item)
                })
                current5++
                GetmyFans(key)
            }
        }
        else{
            current5=1
            console.log("当前的粉丝数组为",FansArray)
            const articleContainer=document.querySelector('.articleContainer')
            articleContainer.innerHTML=``
            const formGroup=document.querySelector('.form-group1')
            formGroup.innerHTML=``
            FansArray.forEach(item=>{
                const div = document.createElement('div')
                div.setAttribute('userId', item.userId)
                //关注者数组是否包含
                let followStatus=followingArray.some(user=>user.userId===item.userId)
                if(followStatus){
                    div.innerHTML = `
                        <div class="tech-item">
                            <div class="tech-left">
                                <div class="tech-icon css-icon">
                                       <img src="${item.avatar}" alt="" style="width: 100%; height: 100%" class="SeeHisPage">
                                </div>
                                <span class="tech-name">${item.username}</span>
                            </div>
                            <button class="follow-btn1 deleteFollow">已关注</button>
                        </div>
                    `
                }
                else{
                    div.innerHTML = `
                        <div class="tech-item">
                            <div class="tech-left">
                                <div class="tech-icon css-icon">
                                       <img src="${item.avatar}" alt="" style="width: 100%; height: 100%" class="SeeHisPage">
                                </div>
                                <span class="tech-name">${item.username}</span>
                            </div>
                            <button class="follow-btn1 prepareFollow">关注</button>
                        </div>`
                }
                articleContainer.appendChild(div)
            })
        }
    }
}


let total=0
let current=1
function GetMyBrowseArticle(key,current){
    /*
    *
    * 要不要每个文章再搞个关注者啥的
    * 我就给每个文章搞个关注成功啥的，不搞深层的嵌套的了
    *
    * */
    let xhr = new XMLHttpRequest();
    xhr.open(
        'GET',
        `http://43.136.111.27:8086/user/get/browsed-articles?current=${current}&size=10`
    )
    xhr.setRequestHeader('Authorization', `${key}`)
    xhr.send()
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            let response = JSON.parse(xhr.responseText);
            console.log(response.data.records)
            total=response.data.pages
            console.log("当前total的值为", total)
            let xhr2=new XMLHttpRequest();
            xhr2.open(
                'GET',
                'http://43.136.111.27:8086/user/follower'
            )
            xhr2.setRequestHeader('Authorization', `${key}`)
            xhr2.send()
            xhr2.onreadystatechange = function () {
                if (xhr2.readyState === 4 && xhr.status === 200) {
                    let response2 = JSON.parse(xhr2.responseText);
                    console.log("当前的关注者请求数据是:",response2)
                    let totalFollower=response2.data.total
                    console.log("总共有关注者",totalFollower)
                    let xhr3=new XMLHttpRequest();
                    xhr3.open(
                        'GET',
                        'http://43.136.111.27:8086/user/following'
                    )
                    xhr3.setRequestHeader('Authorization', `${key}`)
                    xhr3.send()
                    xhr3.onreadystatechange = function () {
                        if (xhr3.readyState === 4 && xhr.status === 200) {
                            let response3 = JSON.parse(xhr3.responseText);
                            console.log("当前的粉丝数为:",response3)
                            let totalFans=response3.data.total
                            console.log("当前有粉丝",totalFans)
                            let xhr4=new XMLHttpRequest();
                            xhr4.open(
                                'GET',
                                'http://43.136.111.27:8086/user/collected-articles'
                            )
                            xhr4.setRequestHeader('Authorization', `${key}`)
                            xhr4.send()
                            xhr4.onreadystatechange = function () {
                                if (xhr4.readyState === 4 && xhr.status === 200) {
                                    let response4 = JSON.parse(xhr4.responseText);
                                    console.log("当前的收藏文章数是:",response4)
                                    let totalArticles=response4.data.total
                                    console.log("当前有收藏文章",totalArticles)
                                    main.innerHTML=`
                    <!-- 个人主页内容 -->
                    <div class="profile-container">
    <!-- 主内容区 -->
    <div class="main-profile">
        <div class="profile-header">
            <img src="${userdata.avatar}" class="user-avatar" alt="用户头像" class="userAvatar2">
            <div class="user-info">
                <h1 class="username">${userdata.username}</h1>
                <div class="questions">
                    <div>+ 你从事什么职业？</div>
                    <div>+ 你的信仰是什么？</div>
                </div>
            </div>
        </div>

        <nav class="profile-nav">
            <div class="nav-item active myBrowseArticle" style="font-size: 13px">浏览记录</div>
            <div class="nav-item systeminform" style="font-size: 13px">系统通知</div>
            <div class="nav-item clearBrowse" style="font-size: 13px">清空</div>
            <div class="nav-item MyFans" style="font-size: 13px">粉丝列表</div>
            <div class="nav-item MyCollectArticle" style="font-size: 13px">我的收藏</div>
            <div class="nav-item Myfollowing" style="font-size: 13px">关注列表</div>
            <div class="nav-item Mywork" style="font-size: 13px">我的作品</div>
            <div class="nav-item Mygood" style="font-size: 13px">点赞记录</div>
        </nav>
        <div class="articleContainer">

        </div>

        <div class="form-group1">
                <label class="form-label1">请输入查询页数:</label>
                <input type="number" class="form-input1 currentPage" value="${current}">
                <label class="form-label1">共:${total}页</label>
                <label class="form-label1">当前为:${current}页</label>
        </div>
    </div>

    <!-- 右侧边栏 -->
    <div class="profile-sidebar">
        <div class="stats-card">
            <div class="stats-row">
                <div class="stat-item">
                    <div class="stat-value">${totalFollower}</div>
                    <div class="stat-label">关注了</div>
                </div>
                <div class="stat-item">
                    <div class="stat-value">${totalFans}</div>
                    <div class="stat-label">粉丝</div>
                </div>
            </div>
            <button class="btn-settings">设置</button>
        </div>

        <div class="stats-card">
            <div class="stats-row">
                <div class="stat-item">
                    <div class="stat-value">${totalArticles}</div>
                    <div class="stat-label">收藏集</div>
                </div>

                 <div class="stat-item">
                    <div class="stat-value">${totalArticles}</div>
                    <div class="stat-label">收藏集</div>
                 </div>
            </div>
        </div>
    </div>
</div>
                `
                                    document.querySelectorAll('.nav-item').forEach(item => {
                                        item.addEventListener('click', function() {
                                            // 移除所有按钮激活状态
                                            document.querySelectorAll('.nav-item').forEach(btn => {
                                                btn.classList.remove('active');
                                            });

                                            // 为当前按钮添加激活状态
                                            this.classList.add('active');

                                            // 触发对应内容区的显示（需自行实现内容切换逻辑）
                                            const tabType = this.textContent.trim();
                                            console.log(`切换到${tabType}页面`);
                                        });
                                    });
                                    //这里已经选中了div了
                                    const articleContainer=document.querySelector('.articleContainer')
                                    articleContainer.innerHTML=``
                                    response.data.records.forEach(item => {
                                        let xhr2=new XMLHttpRequest()
                                        xhr2.open(
                                            'GET',
                                            `http://43.136.111.27:8086/article/detail/${item.articleId}`
                                        )
                                        //看其是否被删除

                                        xhr2.setRequestHeader('Authorization',`${key}`)
                                        xhr2.send()
                                        xhr2.onreadystatechange=function(){
                                            if(xhr2.readyState===4&&xhr2.status===200){
                                                let response2 = JSON.parse(xhr2.responseText)
                                                if(response2.data.isDeleted===0){
                                                    lookArray = []
                                                    //这里创建数组的目的是为了请求数据不出现重复的数组
                                                    const look = {}
                                                    for (const key in item) {
                                                        look[key] = item[key]
                                                    }
                                                    const isexist = lookArray.some(
                                                        existing => existing.articleId === look.articleId
                                                    )
                                                    if (!isexist) {
                                                        lookArray.push(look)
                                                        //创建文章的浏览记录的div
                                                        const div = document.createElement('div')
                                                        div.setAttribute('articleId', response2.data.articleId)
                                                        div.innerHTML = `
                                        <div class="article-card">
            <div class="article-img">
                <img src="${response2.data.coverUrl}" alt="" style="width: 100%; height: 100%">
            </div>
            <div class="article-content">
                <h3>${response2.data.title}</h3>
                <div class="article-tags">
                    <div class="tag">${response2.data.labelId}</div>
                    <div class="tag">${response2.data.tags}</div>
                </div>
                <p class="article-desc">${response2.data.summary}</p>
                <div class="article-meta">
                    <span>发表于:${response2.data.createTime}</span>
                    <span>${response2.data.viewCount} 阅读</span>
                    <span>${response2.data.likeCount} 赞</span>
                    <span>更新于:${response2.data.updateTime}</span>
                </div>
            </div>
        </div>
                                    `
                                                        articleContainer.appendChild(div)
                                                    }
                                                }
                                            }
                                        }
                                    })


                                    const currentPageInput = document.querySelector('.currentPage')
                                    currentPageInput.addEventListener('change', function(){
                                        const newPage = parseInt(this.value);
                                        // 验证输入是否为有效数字且在合理范围
                                        if (!isNaN(newPage) && newPage >= 1 && newPage <= total) {
                                            current = newPage;
                                            GetMyBrowseArticle(key, current); // 重新加载数据
                                        } else {
                                            // 输入无效时恢复当前值
                                            this.value = current;
                                            alert(`请输入 1 到 ${total} 之间的有效页数`);
                                        }
                                    })

                                    /*
                                    *
                                    *
                                    *
                                    *
                                    * 这甚至只是一篇文章，我还要检测他的点赞状态，收藏状态，用户着的关注状态
                                    *
                                    *
                                    *
                                    *
                                    * */


                                    articleContainer.addEventListener('click', function(e) {
                                        if(e.target.closest('div[articleId]')){
                                            const articleId=e.target.closest('div[articleId]').getAttribute('articleId');
                                            console.log("当前我点击的div是:",articleId)
                                            let xhr=new XMLHttpRequest()
                                            xhr.open(
                                                'GET',
                                                `http://43.136.111.27:8086/article/detail/${articleId}`
                                            )
                                            xhr.setRequestHeader('Authorization',`${key}`)
                                            xhr.send()
                                            xhr.onreadystatechange=function(){
                                                if(xhr.readyState===4&&xhr.status===200){
                                                    let response3 = JSON.parse(xhr.responseText)
                                                    console.log("当前获取到的文章内容是:",response3)
                                                    let xhr1=new XMLHttpRequest()
                                                    xhr1.open(
                                                        'GET',
                                                        `http://43.136.111.27:8086/creator/profile/${response3.data.userId}`
                                                    )
                                                    xhr1.setRequestHeader('Authorization',`${key}`)
                                                    xhr1.send()
                                                    xhr1.onreadystatechange=function(){
                                                        if(xhr1.readyState===4&&xhr1.status===200){
                                                            let response4 = JSON.parse(xhr1.responseText)
                                                            console.log("获取到的用户信息是:",response4)
                                                            //response4为创作者的个人信息
                                                            let xhr2=new XMLHttpRequest()
                                                            xhr2.open(
                                                                'GET',
                                                                `http://43.136.111.27:8086/creator/followers/${response4.data.userId}`
                                                            )
                                                            xhr2.setRequestHeader('Authorization',`${key}`)
                                                            xhr2.send()
                                                            xhr2.onreadystatechange=function(){
                                                                if(xhr2.readyState===4&&xhr2.status===200){
                                                                    let response5 = JSON.parse(xhr2.responseText)
                                                                    console.log(response5)
                                                                    let totalFans= response5.data.total
                                                                    console.log("当前粉丝数为:",totalFans)
                                                                    let xhr3=new XMLHttpRequest()
                                                                    xhr3.open(
                                                                        'GET',
                                                                        `http://43.136.111.27:8086/creator/following/${response4.data.userId}`
                                                                    )
                                                                    xhr3.setRequestHeader('Authorization',`${key}`)
                                                                    xhr3.send()
                                                                    xhr3.onreadystatechange=function(){
                                                                        if(xhr3.readyState===4&&xhr3.status===200){
                                                                            let response6 = JSON.parse(xhr3.responseText)
                                                                            console.log("当前的关注人数是:",response6)
                                                                            let totalFollowing=response6.data.total
                                                                            console.log("当前的关注者人数为:",totalFollowing)
                                                                            let xhr4=new XMLHttpRequest()
                                                                            xhr4.open(
                                                                                'GET',
                                                                                `http://43.136.111.27:8086/article/comment/list/${response3.data.articleId}`
                                                                            )
                                                                            xhr4.setRequestHeader('Authorization',`${key}`)
                                                                            xhr4.send()
                                                                            xhr4.onreadystatechange=function(){
                                                                                if(xhr4.readyState===4&&xhr4.status===200){
                                                                                    let response7 = JSON.parse(xhr4.responseText)
                                                                                    console.log("当前的评论数为:",response7)
                                                                                    let totalComment=response7.data.length
                                                                                    console.log("当前评论数为:",totalComment)
                                                                                    let xhr5=new XMLHttpRequest()
                                                                                    xhr5.open(
                                                                                        'GET',
                                                                                        `http://43.136.111.27:8086/article/following-articles?current=1&size=10&followerId=${response4.data.userId}`
                                                                                    )
                                                                                    xhr5.setRequestHeader('Authorization',`${key}`)
                                                                                    xhr5.send()
                                                                                    xhr5.onreadystatechange=function(){
                                                                                        if(xhr5.readyState===4&&xhr5.status===200){
                                                                                            let response8 = JSON.parse(xhr5.responseText)
                                                                                            console.log(response8)
                                                                                            let totalArticles=response8.data.total
                                                                                            console.log("当前的文章数是:",totalArticles)
                                                                                            console.log("当前我关注的数组是:",followingArray)
                                                                                            main.innerHTML=`
                                                                            <!-- 新增顶部返回栏 -->
                                                                            <main style="margin-top: 10px">
                                                                                <div class="article-page">
                                                                                    <!-- 左侧互动栏 -->
                                                                                    <div class="action-sidebar">
                                                                                        <div class="action-item">
                                                                                            <div class="count backTopersonal">返回个人中心</div>
                                                                                        </div>
                                                                                        <div class="action-item">
                                                                                            <svg width="24" height="24" viewBox="0 0 48 48" fill="#1E80FF"> <!-- 新增评论图标 -->
                                                                                                <path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm-2-22h4v12h-4zm0-6h4v4h-4z"/>
                                                                                            </svg>
                                                                                            <div class="count">浏览数:${response3.data.viewCount}</div>
                                                                                        </div>
                                                                                        <div class="action-item collectitem">
                                                                                            <svg width="24" height="24" viewBox="0 0 48 48" fill="#FFB121">
                                                                                                <path d="M24 40.2l-12.6 6.6 3.2-14.4L.4 18.6l14.6-1.2L24 4l9 13.4 14.6 1.2-10.2 9.8 3.2 14.4z"/>
                                                                                            </svg>
                                                                                            <div class="count">收藏数:${response3.data.collectCount}</div>
                                                                                            <div class="count prepareCollect">(未收藏)</div>
                                                                                        </div>
                                                                                        <!-- 点赞 -->
                                                                                        <div class="action-item gooditem" style="color:#FF4756">
                                                                                            <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
                                                                                                <path d="M2 8.4C2 5 4 3 7 3h1c2 0 4 1 5 3l2 3h3c3 0 5 2 5 5v3c0 3-2 5-5 5H6c-2 0-4-1-4-4v-9z"/>
                                                                                            </svg>
                                                                                            <div class="count">点赞数:${response3.data.likeCount}</div>
                                                                                            <div class="count preparegood">(未点赞)</div>
                                                                                        </div>

                                                                                        <!-- 评论 -->
                                                                                        <div class="action-item" style="color:#1E80FF">
                                                                                            <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
                                                                                                <path d="M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h14l4 4V4c0-1.1-.9-2-2-2zm-3 12H7v-2h10v2zm0-3H7V9h10v2zm0-3H7V6h10v2z"/>
                                                                                            </svg>
                                                                                            <div class="count">评论数:${totalComment}</div>

                                                                                        </div>
                                                                                    </div>

                                                                                    <!-- 中间文章内容 -->
                                                                                    <div class="article-main">
                                                                                        <div class="article-header">
                                                                                            <h1 class="title">${response3.data.title}</h1>
                                                                                        </div>

                                                                                        <div class="article-content">
                                                                                            <p class="highlight">${response3.data.content}</p>


                                                                                            <div class="keywords">
                                                                                                <span>${response3.data.tags}</span>
                                                                                                <span>${response3.data.labelId}</span>
                                                                                            </div>
                                                                                        </div>

                                                                                        <div class="commentContainer">
                                                                                            <div class="createComment">
                                                                                                <h6>来发布你的评论吧</h6>
                                                                                                <div><input type="text" class="nullContent" placeholder="请输入文本"></div>
                                                                                                <div><input type="text" class="nullimageUrl" placeholder="请输入图片网址"></div>
                                                                                                <div><button class="submitnull">发布</button></div>
                                                                                            </div>
                                                                                            <div class="createBackComment" style="display: none">
                                                                                                <h6>来发布你的回复吧</h6>
                                                                                                <div><input type="text" class="parContent" placeholder="请输入回复文本"></div>
                                                                                                <div><input type="text" class="parimageUrl" placeholder="请输入回复图片网址"></div>
                                                                                                <div><button class="submitpar">发布</button></div>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>

                                                                                    <!-- 右侧用户信息 -->
                                                                                    <div class="user-sidebar">
                                                                                        <div class="user-card">
                                                                                            <div class="user-header"> <!-- 新增flex容器 -->
                                                                                                <img src="${response4.data.avatar}" class="user-avatar" style="width:60px;height:60px">
                                                                                                <div class="user-info">
                                                                                                    <h3>${response4.data.username}</h3>
                                                                                                    <p class="position">${response4.data.profession}</p>
                                                                                                </div>
                                                                                            </div>

                                                                                            <div class="stats">
                                                                                                <div>
                                                                                                    <div class="number">${totalArticles}</div>
                                                                                                    <div class="label">文章</div>
                                                                                                </div>
                                                                                                <div>
                                                                                                    <div class="number">${totalFollowing}</div>
                                                                                                    <div class="label">关注</div>
                                                                                                </div>
                                                                                                <div>
                                                                                                    <div class="number">${totalFans}</div>
                                                                                                    <div class="label">粉丝</div>
                                                                                                </div>
                                                                                            </div>

                                                                                            <div class="actions isFollow">
                                                                                                <button class="follow-btn prepareFollowing">关注</button>
                                                                                                <button class="message-btn">私信</button>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </main>
                                                                        `
                                                                                            const isFollow=document.querySelector('.isFollow')
                                                                                            let followStatus=followingArray.some(user=>user.userId===response4.data.userId)
                                                                                            if(followStatus){
                                                                                                isFollow.innerHTML=`
                                                                                                        <button class="follow-btn deleteFollowing">取消关注</button>
                                                                                                        <button class="message-btn">私信</button>
                                                                                                    `
                                                                                            }

                                                                                            isFollow.addEventListener('click',function (e){
                                                                                                if(e.target.closest('.deleteFollowing')){
                                                                                                    isFollow.innerHTML=`
                                                                                                            <button class="follow-btn prepareFollowing">关注</button>
                                                                                                            <button class="message-btn">私信</button>
                                                                                                        `
                                                                                                    followingArray = followingArray.filter(user => String(user.userId) !== String(response4.data.userId));
                                                                                                    console.log("当前的关注者数组是",followingArray)
                                                                                                    /*
                                                                                                    *
                                                                                                    * 在这里写请求就行
                                                                                                    *
                                                                                                    * */
                                                                                                    const data={
                                                                                                        userId:response4.data.userId
                                                                                                    }
                                                                                                    let xhr = new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/user/unfollow`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.setRequestHeader('Content-Type','application/json')
                                                                                                    xhr.send(JSON.stringify(data))
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log(xhr.response)
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                if(e.target.closest('.prepareFollowing')){
                                                                                                    isFollow.innerHTML=`
                                                                                                            <button class="follow-btn deleteFollowing">取消关注</button>
                                                                                                            <button class="message-btn">私信</button>
                                                                                                        `
                                                                                                    followingArray.push(response4.data)
                                                                                                    console.log("当前的关注者数组是",followingArray)
                                                                                                    const data={
                                                                                                        userId:response4.data.userId
                                                                                                    }

                                                                                                    /*
                                                                                                    * 在这里写请求就行
                                                                                                    *
                                                                                                    * */
                                                                                                    let xhr = new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/user/follow`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.setRequestHeader('Content-Type','application/json')
                                                                                                    xhr.send(JSON.stringify(data))
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log(xhr.response)
                                                                                                        }
                                                                                                    }

                                                                                                }
                                                                                            })

                                                                                            const collectitem= document.querySelector('.collectitem')
                                                                                            let collectstatus=collectArray.some(article=>article.articleId===response3.data.articleId)
                                                                                            if(collectstatus){
                                                                                                collectitem.innerHTML=`
                                                                                                        <svg width="24" height="24" viewBox="0 0 48 48" fill="#FFB121">
                                                                                                            <path d="M24 40.2l-12.6 6.6 3.2-14.4L.4 18.6l14.6-1.2L24 4l9 13.4 14.6 1.2-10.2 9.8 3.2 14.4z"/>
                                                                                                        </svg>
                                                                                                        <div class="count">收藏数:${response3.data.collectCount}</div>
                                                                                                        <div class="count deleteCollect">(已收藏)</div>
                                                                                                    `
                                                                                            }
                                                                                            let currentcollect=response3.data.collectCount
                                                                                            collectitem.addEventListener('click',function (e){

                                                                                                if(e.target.closest('.deleteCollect')){
                                                                                                    currentcollect--
                                                                                                    collectitem.innerHTML=`
                                                                                                            <svg width="24" height="24" viewBox="0 0 48 48" fill="#FFB121">
                                                                                                                <path d="M24 40.2l-12.6 6.6 3.2-14.4L.4 18.6l14.6-1.2L24 4l9 13.4 14.6 1.2-10.2 9.8 3.2 14.4z"/>
                                                                                                            </svg>
                                                                                                            <div class="count">收藏数:${currentcollect}</div>
                                                                                                            <div class="count prepareCollect">(未收藏)</div>
                                                                                                        `
                                                                                                    collectArray=collectArray.filter(article=>String(article.articleId)!==String(response3.data.articleId))
                                                                                                    console.log("当前的收藏数组为",collectArray)
                                                                                                    /*
                                                                                                    *
                                                                                                    * 这里写取消关注按钮
                                                                                                    *
                                                                                                    * */
                                                                                                    let xhr= new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/uncollect/${response3.data.articleId}`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send()
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log("取消收藏的情况为:",xhr.response)
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                                if(e.target.closest('.prepareCollect')){
                                                                                                    currentcollect++
                                                                                                    collectitem.innerHTML=`
                                                                                                            <svg width="24" height="24" viewBox="0 0 48 48" fill="#FFB121">
                                                                                                                <path d="M24 40.2l-12.6 6.6 3.2-14.4L.4 18.6l14.6-1.2L24 4l9 13.4 14.6 1.2-10.2 9.8 3.2 14.4z"/>
                                                                                                            </svg>
                                                                                                            <div class="count">收藏数:${currentcollect}</div>
                                                                                                            <div class="count deleteCollect">(已收藏)</div>
                                                                                                        `
                                                                                                    collectArray.push(response3.data)
                                                                                                    console.log("当前的收藏数组是",collectArray)
                                                                                                    /*
                                                                                                    * 这里写收藏按钮
                                                                                                    *
                                                                                                    * */
                                                                                                    let xhr= new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/collect/${response3.data.articleId}`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send()
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log("收藏的情况为:",xhr.response)
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            })


                                                                                            const gooditem= document.querySelector('.gooditem')
                                                                                            let goodstatus=likeArray.some(article=>article.articleId===response3.data.articleId)
                                                                                            if(goodstatus){
                                                                                                gooditem.innerHTML=`
                                                                                                       <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
                                                                                                                <path d="M2 8.4C2 5 4 3 7 3h1c2 0 4 1 5 3l2 3h3c3 0 5 2 5 5v3c0 3-2 5-5 5H6c-2 0-4-1-4-4v-9z"/>
                                                                                                       </svg>
                                                                                                       <div class="count">点赞数:${response3.data.likeCount}</div>
                                                                                                       <div class="count deletegood">(取消点赞)</div>
                                                                                                    `
                                                                                            }
                                                                                            let currentgood=response3.data.likeCount
                                                                                            gooditem.addEventListener('click',function (e){
                                                                                                if(e.target.closest('.deletegood')){
                                                                                                    currentgood--
                                                                                                    gooditem.innerHTML=`
                                                                                                            <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
                                                                                                                <path d="M2 8.4C2 5 4 3 7 3h1c2 0 4 1 5 3l2 3h3c3 0 5 2 5 5v3c0 3-2 5-5 5H6c-2 0-4-1-4-4v-9z"/>
                                                                                                            </svg>
                                                                                                            <div class="count">点赞数:${currentgood}</div>
                                                                                                            <div class="count preparegood">(未点赞)</div>
                                                                                                        `
                                                                                                    likeArray=likeArray.filter(article => String(article.articleId)!==String(response3.data.articleId))
                                                                                                    console.log("当前的喜欢文章数组是",likeArray)
                                                                                                    let xhr = new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/unlike/${response3.data.articleId}`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send()
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log("取消点赞为:",xhr.response)
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                if(e.target.closest('.preparegood')){
                                                                                                    currentgood++
                                                                                                    gooditem.innerHTML=`
                                                                                                           <svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor">
                                                                                                                    <path d="M2 8.4C2 5 4 3 7 3h1c2 0 4 1 5 3l2 3h3c3 0 5 2 5 5v3c0 3-2 5-5 5H6c-2 0-4-1-4-4v-9z"/>
                                                                                                           </svg>
                                                                                                           <div class="count">点赞数:${currentgood}</div>
                                                                                                           <div class="count deletegood">(取消点赞)</div>
                                                                                                        `
                                                                                                    likeArray.push(response3.data)
                                                                                                    console.log("当前的喜欢文章数组是",likeArray)
                                                                                                    let xhr = new XMLHttpRequest();
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/like/${response3.data.articleId}`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send()
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log("点赞情况为:",xhr.response)
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            })

                                                                                            console.log("当前的评论为:",response7)
                                                                                            const commentContainer=document.querySelector('.commentContainer')
                                                                                            response7.data.forEach(item => {
                                                                                                //判断这个文章的父亲id为0同时这个评论的
                                                                                                console.log("这个评论是",item)
                                                                                                let xhr = new XMLHttpRequest();
                                                                                                xhr.open(
                                                                                                    'GET',
                                                                                                    `http://43.136.111.27:8086/creator/profile/${item.commentUser}`
                                                                                                )
                                                                                                xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                xhr.send()
                                                                                                xhr.onreadystatechange=function (){
                                                                                                    if(xhr.readyState===4&&xhr.status===200){
                                                                                                        let response14=JSON.parse(xhr.responseText)
                                                                                                        console.log("当前评论的用户信息是",response14.data)
                                                                                                        if(item.parentId==null&&item.commentUser!=userdata.userId&&item.isDeleted==0){
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${item.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${response14.data.avatar}"><span>${response14.data.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${item.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${item.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${item.createTime}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            console.log("当前的这个评论div是",div)
                                                                                                            commentContainer.appendChild(div)
                                                                                                        }
                                                                                                        if(item.parentId==null&&item.commentUser==userdata.userId&&item.isDeleted==0){
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${item.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${response14.data.avatar}"><span>${response14.data.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${item.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${item.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${item.createTime}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                            <button class="deleteComment">删除</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            console.log("当前的这个评论div是",div)
                                                                                                            commentContainer.appendChild(div)
                                                                                                        }
                                                                                                        if(item.parentId!=null&&item.commentUser==userdata.userId&&item.isDeleted==0){
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${item.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${response14.data.avatar}"><span>${response14.data.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${item.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${item.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${item.createTime}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                            <button class="deleteComment">删除</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            const parentdiv=document.querySelector(`.commentItem[commentId="${item.parentId}"]`)
                                                                                                            console.log("这个孩子评论为:",div)
                                                                                                            console.log("选中的父亲id是",item.parentId)
                                                                                                            console.log("选中的父亲元素是",parentdiv)
                                                                                                            const childrenComment=parentdiv.querySelector('.childrenComment')
                                                                                                            childrenComment.appendChild(div)
                                                                                                        }
                                                                                                        if(item.parentId!=null&&item.commentUser!=userdata.userId&&item.isDeleted==0){
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${item.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${response14.data.avatar}"><span>${response14.data.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${item.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${item.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${item.createTime}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            const parentdiv=document.querySelector(`.commentItem[commentId="${item.parentId}"]`)
                                                                                                            console.log("选中的父亲元素是",parentdiv)
                                                                                                            const childrenComment=parentdiv.querySelector('.childrenComment')
                                                                                                            childrenComment.appendChild(div)
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                            })

                                                                                            let parentId=null
                                                                                            commentContainer.addEventListener('click',function (e1){
                                                                                                if(e1.target.closest('.backComment1')){
                                                                                                    alert('回复评论被点击')
                                                                                                    const div=e1.target.closest('div[commentId]')
                                                                                                    parentId=div.getAttribute('commentId')
                                                                                                    console.log("当前回复的父亲id是:",parentId)
                                                                                                    const createBackComment=document.querySelector('.createBackComment')
                                                                                                    createBackComment.style.display='block'
                                                                                                }

                                                                                                if(e1.target.closest('.submitpar')){
                                                                                                    alert('提交回复被点击')
                                                                                                    const parContent=document.querySelector('.parContent').value
                                                                                                    const parimageUrl=document.querySelector('.parimageUrl').value
                                                                                                    const data={
                                                                                                        articleId:response3.data.articleId,
                                                                                                        content:parContent,
                                                                                                        imageUrl:parimageUrl,
                                                                                                        parentId:parentId,
                                                                                                    }
                                                                                                    console.log("当前发送的数据是:",data)
                                                                                                    // 清空输入框并隐藏
                                                                                                    document.querySelector('.parContent').value = '';
                                                                                                    document.querySelector('.parimageUrl').value = '';
                                                                                                    document.querySelector('.createBackComment').style.display = 'none';
                                                                                                    //在这里服务器确实返回了commentId
                                                                                                    let xhr = new XMLHttpRequest()
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/comment/add`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Content-Type', 'application/json')
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send(JSON.stringify(data))
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            let response16=JSON.parse(xhr.responseText)
                                                                                                            console.log("发送评论情况为:",response16)
                                                                                                            const formatTime = () => {
                                                                                                                const now = new Date();
                                                                                                                const year = now.getFullYear();
                                                                                                                const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始要+1
                                                                                                                const day = String(now.getDate()).padStart(2, '0');
                                                                                                                const hours = String(now.getHours()).padStart(2, '0');
                                                                                                                const minutes = String(now.getMinutes()).padStart(2, '0');
                                                                                                                const seconds = String(now.getSeconds()).padStart(2, '0');

                                                                                                                return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
                                                                                                            };
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${response16.data.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${userdata.avatar}"><span>${userdata.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${data.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${data.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${formatTime()}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                            <button class="deleteComment">删除</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            const parentdiv=document.querySelector(`.commentItem[commentId="${data.parentId}"]`)
                                                                                                            console.log("这个孩子评论为:",div)
                                                                                                            console.log("选中的父亲id是",data.parentId)
                                                                                                            console.log("选中的父亲元素是",parentdiv)
                                                                                                            const childrenComment=parentdiv.querySelector('.childrenComment')
                                                                                                            childrenComment.appendChild(div)
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                if(e1.target.closest('.deleteComment')){
                                                                                                    alert('删除按钮被点击')
                                                                                                    const div=e1.target.closest('.commentItem[commentId]')
                                                                                                    //这里是选父亲元素
                                                                                                    commentId=div.getAttribute('commentId')
                                                                                                    console.log("当前删除的最近元素id是:",commentId)
                                                                                                    div.remove()
                                                                                                    let xhr = new XMLHttpRequest()
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/comment/delete/${commentId}`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send()
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            console.log("删除情况为:",xhr.responseText)
                                                                                                        }
                                                                                                    }
                                                                                                }

                                                                                                if(e1.target.closest('.submitnull')){
                                                                                                    alert('提交评论被点击')
                                                                                                    const nullContent=document.querySelector('.nullContent').value
                                                                                                    const nullimageUrl=document.querySelector('.nullimageUrl').value
                                                                                                    const data={
                                                                                                        articleId:response3.data.articleId,
                                                                                                        content:nullContent,
                                                                                                        imageUrl:nullimageUrl,
                                                                                                        parentId:null
                                                                                                    }
                                                                                                    console.log("上传的null数据是",data)
                                                                                                    let xhr = new XMLHttpRequest()
                                                                                                    xhr.open(
                                                                                                        'POST',
                                                                                                        `http://43.136.111.27:8086/article/comment/add`
                                                                                                    )
                                                                                                    xhr.setRequestHeader('Content-Type', 'application/json')
                                                                                                    xhr.setRequestHeader('Authorization',`${key}`)
                                                                                                    xhr.send(JSON.stringify(data))
                                                                                                    xhr.onreadystatechange=function (){
                                                                                                        if(xhr.readyState===4&&xhr.status===200){
                                                                                                            let response16=JSON.parse(xhr.responseText)
                                                                                                            console.log("发送null评论情况为:",response16)
                                                                                                            const formatTime = () => {
                                                                                                                const now = new Date();
                                                                                                                const year = now.getFullYear();
                                                                                                                const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始要+1
                                                                                                                const day = String(now.getDate()).padStart(2, '0');
                                                                                                                const hours = String(now.getHours()).padStart(2, '0');
                                                                                                                const minutes = String(now.getMinutes()).padStart(2, '0');
                                                                                                                const seconds = String(now.getSeconds()).padStart(2, '0');

                                                                                                                return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
                                                                                                            };
                                                                                                            const div=document.createElement('div')
                                                                                                            div.innerHTML=`
                                                                                                                    <div class="commentItem" commentId="${response16.data.commentId}">
                                                                                                                        <div>
                                                                                                                        <img class="commentAvatar" src="${userdata.avatar}"><span>${userdata.username}</span>
                                                                                                                        </div>
                                                                                                                        <div class="commentContent">${data.content}</div>
                                                                                                                        <div class="commentIMG"><img src="${data.imageUrl}" alt="" style="width: 100%;height: 100%"></div>
                                                                                                                        <div class="commentTime">${formatTime()}</div>
                                                                                                                        <div class="backComment">
                                                                                                                            <button class="backComment1">回复</button>
                                                                                                                            <button class="deleteComment">删除</button>
                                                                                                                        </div>
                                                                                                                        <div class="childrenComment"></div>
                                                                                                                    </div>
                                                                                                                `
                                                                                                            commentContainer.appendChild(div)
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            })
                                                                                        }
                                                                                    }

                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            //这里能填充用户的粉丝数，关注数,但是很麻烦

                                                        }
                                                    }
                                                }
                                            }
                                        }

                                    })
                                }
                            }
                        }
                    }
                }
            }


        }
    }
}

let mywork=[]
let current1=1
function getMywork(key){
    //我打算从top文章下手
    //循环发送请求,直到得到的长度为0
    let xhr=new XMLHttpRequest()
    xhr.open(
        //网址为路径参数
        'GET',
        `http://43.136.111.27:8086/article/top?current=${current1}`
    )
    xhr.send()
    xhr.onreadystatechange=function(){
        if(xhr.readyState===4&&xhr.status===200){
            let response=JSON.parse(xhr.responseText)
            let records=response.data.records
            console.log(response.data)
            if(records.length>0){
                // 筛选符合条件的数据
                records.forEach(item=>{
                    let xhr2=new XMLHttpRequest()
                    xhr2.open(
                        'GET',
                        `http://43.136.111.27:8086/article/detail/${item.articleId}`
                    )
                    //看其是否被删除
                    xhr2.setRequestHeader('Authorization',`${key}`)
                    xhr2.send()
                    xhr2.onreadystatechange=function(){
                        if(xhr2.readyState===4&&xhr2.status===200){
                            let detailresponse=JSON.parse(xhr2.responseText)
                            console.log("当前文章的情况是",detailresponse)
                            if(detailresponse.data.userId===userdata.userId&&detailresponse.data.isDeleted!==1){
                                mywork.push(detailresponse.data)
                            }
                        }
                    }
                })
                current1++; // 增加页码以便下一次请求
                getMywork(); // 继续请求下一页数据
            }
            else{
                console.log("所有参数已经加载完成:",mywork)
                current1=1
                const articleContainer=document.querySelector('.articleContainer')
                articleContainer.innerHTML=``
                const formGroup=document.querySelector('.form-group1')
                formGroup.innerHTML=``
                mywork.forEach(item=>{
                    const div = document.createElement('div')
                    div.setAttribute('articleId', item.articleId)
                    div.innerHTML = `
                                        <div class="article-card">
            <div class="article-img">
                <img src="${item.coverUrl}" alt="" style="width: 100%; height: 100%">
            </div>
            <div class="article-content">
                <h3>${item.title}</h3>
                <div class="article-tags">
                    <div class="tag">${item.labelId}</div>
                    <div class="tag">${item.tags}</div>
                </div>
                <p class="article-desc">${item.summary}</p>
                <div class="article-meta">
                    <span>发表于:${item.createTime}</span>
                    <span>${item.viewCount} 阅读</span>
                    <span>${item.likeCount} 赞</span>
                    <span>更新于:${item.updateTime}</span>
                </div>
            </div>
        </div>
                                    `
                    articleContainer.appendChild(div)
                })
            }
        }

    }
}
